package com.example.lenovo.democ;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddStuScoreActivity extends AppCompatActivity {
    private EditText edit_name,edit_android,edit_english;
    private Button btn_add;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_stu_score);
        //定义组件
        findViews();

        //添加分数
        AddScores();
    }

    /**
     *   添加分数
     */
    private void AddScores() {
        btn_add=findViewById(R.id.btn_add);
        btn_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name=edit_name.getText().toString();
                int android=Integer.parseInt(edit_android.getText().toString());
                int english=Integer.parseInt(edit_english.getText().toString());
                Intent intent=new Intent();
                intent.putExtra("NAME",name);
                intent.putExtra("ANDROID",android);
                intent.putExtra("ENGLISH",english);
                setResult(2001,intent);
                finish();
            }
        });
    }

    /**
     *   定义组件
     */
    private void findViews() {
        edit_name=findViewById(R.id.edit_name);
        edit_android=findViewById(R.id.edit_android);
        edit_english=findViewById(R.id.edit_english);

    }
}
